package ch.zbw.swt.sysventory.ui;

import java.awt.Color;
import java.awt.Dimension;
import java.awt.EventQueue;
import java.awt.Font;
import java.awt.Toolkit;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;

import javax.swing.Action;
import javax.swing.ImageIcon;
import javax.swing.JButton;
import javax.swing.JFrame;
import javax.swing.JLabel;
import javax.swing.JPanel;

import IMG.GetPath;
import java.awt.GridLayout;
import java.awt.BorderLayout;
import javax.swing.JScrollPane;
import javax.swing.JList;
import javax.swing.AbstractListModel;
import javax.swing.ScrollPaneConstants;
import javax.swing.JTable;
import javax.swing.table.DefaultTableModel;

/*
 * GUI zeigt das Resultat der Suche an
 */

public class GUIGefundeneObjekte extends JFrame{

	//Panels
	private JPanel panel;
	private JPanel mainPanel;
	private JPanel compVersPanel; 
	
	private JScrollPane scrollPane;
	
	//Bilder
	private ImageIcon goArrow;
	private ImageIcon backArrow;
	
	//Labels
	private JLabel menuTitelLabel;
	private JLabel computerTitelLabel;
	private JLabel computerNameLabel;
	private JLabel datumTitelLabel;
	private JLabel datumDatumLabel;
	private JLabel versionTitelLabel;
	private JLabel versionVersionLabel; 
	
	//Buttons
	private JButton back2MenuButton;
	
	//Tabelle
	private JTable table;
	
	//Listener
	private Action action;

	/**
	 * Konstruktor der GUI
	 */
	public GUIGefundeneObjekte(Action action) {
		this.action = action;
	}

	/**
	 * Initialisierung der GUI
	 */
	public void initialize() {
		
		//Eigenschaften von GUI
		this.getContentPane().setBackground(Color.WHITE);
		this.setBackground(Color.WHITE);
		this.setBounds(100, 100, 770, 480);
		
		//Einmittung
		Dimension screenSize = Toolkit.getDefaultToolkit().getScreenSize();
		int top = (screenSize.height - this.getHeight()) / 2;
		int left = (screenSize.width - this.getWidth()) / 2;
		this.setLocation(left, top);
		
		//weitere Eigenschaften der GUI
		this.setResizable(false);
		this.setVisible(true);
		
		//Einfügen von Elemente
		panel = new JPanel();
		panel.setBackground(Color.WHITE);
		panel.setBounds(10, 11, 744, 83);
		this.getContentPane().add(panel);
		panel.setLayout(null);
		
		goArrow = new ImageIcon(GetPath.class.getResource("go.png"));			
		backArrow = new ImageIcon(GetPath.class.getResource("back.png"));
		
		back2MenuButton = new JButton(backArrow);
		back2MenuButton.setBackground(Color.WHITE);
		back2MenuButton.setBounds(24, 11, 129, 61);
		back2MenuButton.setBorder(null);
		panel.add(back2MenuButton);
		
		mainPanel = new JPanel();
		mainPanel.setBounds(10, 183, 744, 227);
		panel.add(mainPanel);
		mainPanel.setLayout(new BorderLayout(0, 0));
		
		scrollPane = new JScrollPane();
		mainPanel.add(scrollPane, BorderLayout.CENTER);
		
		table = new JTable();
		table.setModel(new DefaultTableModel(
			new Object[][] {
				{null, null, null, null, null, null, null, null},
				{null, null, null, null, null, null, null, null},
				{null, null, null, null, null, null, null, null},
				{null, null, null, null, null, null, null, null},
				{null, null, null, null, null, null, null, null},
				{null, null, null, null, null, null, null, null},
				{null, null, null, null, null, null, null, null},
				{null, null, null, null, null, null, null, null},
				{null, null, null, null, null, null, null, null},
				{null, null, null, null, null, null, null, null},
				{null, null, null, null, null, null, null, null},
				{null, null, null, null, null, null, null, null},
				{null, null, "", null, null, null, null, null},
				{null, null, null, null, null, null, null, null},
				{null, null, null, null, null, null, null, null},
				{null, null, null, null, null, null, null, null},
				{null, null, null, null, null, null, null, null},
				{null, null, null, null, null, null, null, null},
				{null, null, null, null, null, null, null, null},
				{null, null, null, null, null, null, null, null},
				{null, null, null, null, null, null, null, null},
				{null, null, null, null, null, null, null, null},
				{null, null, null, null, null, null, null, null},
				{null, null, null, null, null, null, null, null},
				{null, null, null, null, null, null, null, null},
				{null, null, null, null, null, null, null, null},
				{null, null, null, null, null, null, null, null},
				{null, null, null, null, null, null, null, null},
				{null, null, null, null, null, null, null, null},
				{null, null, null, null, null, null, null, null},
				{null, null, null, null, null, null, null, null},
				{null, null, null, null, null, null, null, null},
				{null, null, null, null, null, null, null, null},
				{null, null, null, null, null, null, null, null},
				{null, null, null, null, null, null, null, null},
				{null, null, null, null, null, null, null, null},
				{null, null, null, null, null, null, null, null},
				{null, null, null, null, null, null, null, null},
				{null, null, null, null, null, null, null, null},
				{null, null, null, null, null, null, null, null},
				{null, null, null, null, null, null, null, null},
				{null, null, null, null, null, null, null, null},
				{null, null, null, null, null, null, null, null},
				{null, null, null, null, null, null, null, null},
				{null, null, null, null, null, null, null, null},
				{null, null, null, null, null, null, null, null},
				{null, null, null, null, null, null, null, null},
				{null, null, null, null, null, null, null, null},
				{null, null, null, null, null, null, null, null},
				{null, null, null, null, null, null, null, null},
				{null, null, null, null, null, null, null, null},
				{null, null, null, null, null, null, null, null},
				{null, null, null, null, null, null, null, null},
				{null, null, null, null, null, null, null, null},
				{null, null, null, null, null, null, null, null},
				{null, null, null, null, null, null, null, null},
				{null, null, null, null, null, null, null, null},
				{null, null, null, null, null, null, null, null},
				{null, null, null, null, null, null, null, null},
				{null, null, null, null, null, null, null, null},
				{null, null, null, null, null, null, null, null},
				{null, null, null, null, null, null, null, null},
				{null, null, null, null, null, null, null, null},
				{null, null, null, null, null, null, null, null},
				{null, null, null, null, null, null, null, null},
				{null, null, null, null, null, null, null, null},
				{null, null, null, null, null, null, null, null},
				{null, null, null, null, null, null, null, null},
				{null, null, null, null, null, null, null, null},
				{null, null, null, null, null, null, null, null},
				{null, null, null, null, null, null, null, null},
				{null, null, null, null, null, null, null, null},
				{null, null, null, null, null, null, null, null},
				{null, null, null, null, null, null, null, null},
				{null, null, null, null, null, null, null, null},
				{null, null, null, null, null, null, null, null},
				{null, null, null, null, null, null, null, null},
				{null, null, null, null, null, null, null, null},
				{null, null, null, null, null, null, null, null},
				{null, null, null, null, null, null, null, null},
				{null, null, null, null, null, null, null, null},
				{null, null, null, null, null, null, null, null},
				{null, null, null, null, null, null, null, null},
				{null, null, null, null, null, null, null, null},
				{null, null, null, null, null, null, null, null},
				{null, null, null, null, null, null, null, null},
				{null, null, null, null, null, null, null, null},
				{null, null, null, null, null, null, null, null},
				{null, null, null, null, null, null, null, null},
				{null, null, null, null, null, null, null, null},
				{null, null, null, null, null, null, null, null},
				{null, null, null, null, null, null, null, null},
				{null, null, null, null, null, null, null, null},
				{null, null, null, null, null, null, null, null},
				{null, null, null, null, null, null, null, null},
				{null, null, null, null, null, null, null, null},
				{null, null, null, null, null, null, null, null},
				{null, null, null, null, null, null, null, null},
				{null, null, null, null, null, null, null, null},
				{null, null, null, null, null, null, null, null},
			},
			new String[] {
				"Computername", "Ktriterium2", "Ktriterium3", "Ktriterium4", "Kriterium5", "Kriterium6", "Kriterium7", "Kriterium8"
			}
		));
		scrollPane.setViewportView(table);
		
		compVersPanel = new JPanel();
		compVersPanel.setBackground(Color.WHITE);
		compVersPanel.setBounds(97, 74, 562, 50);
		panel.add(compVersPanel);
		compVersPanel.setLayout(new GridLayout(0, 6, 0, 0));
		
		computerTitelLabel = new JLabel("Computer:");
		computerTitelLabel.setFont(new Font("Tahoma", Font.BOLD, 12));
		compVersPanel.add(computerTitelLabel);
		
		computerNameLabel = new JLabel("\"Name\"");
		computerNameLabel.setFont(new Font("Tahoma", Font.PLAIN, 12));
		compVersPanel.add(computerNameLabel);
		
		datumTitelLabel = new JLabel("Datum:");
		datumTitelLabel.setFont(new Font("Tahoma", Font.BOLD, 12));
		compVersPanel.add(datumTitelLabel);
		
		datumDatumLabel = new JLabel("11.06.2013");
		datumDatumLabel.setFont(new Font("Tahoma", Font.PLAIN, 12));
		compVersPanel.add(datumDatumLabel);
		
		versionTitelLabel = new JLabel("Version:");
		versionTitelLabel.setFont(new Font("Tahoma", Font.BOLD, 12));
		compVersPanel.add(versionTitelLabel);
		
		versionVersionLabel = new JLabel("\"Vers.Nummer\"");
		versionVersionLabel.setFont(new Font("Tahoma", Font.PLAIN, 12));
		compVersPanel.add(versionVersionLabel);
		
		menuTitelLabel = new JLabel("Gefundene Objekte");
		menuTitelLabel.setFont(new Font("Impact", Font.PLAIN, 36));
		menuTitelLabel.setBounds(225, 11, 316, 61);
		panel.add(menuTitelLabel);
		
		
		//Einfügen der Actionlistener
		back2MenuButton.addActionListener(action);
		back2MenuButton.setActionCommand("back2Menu");
		
	}
}
